package com.ruoyi.web.wapper;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.enums.BaseStatusEnum;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import com.ruoyi.market.enums.InfoTypeEnum;
import com.ruoyi.market.enums.PriceTypeEnum;
import com.ruoyi.product.enums.ProdPriceEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class SourceBaseInfoWapper extends BaseControllerWrapper {

    public SourceBaseInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public SourceBaseInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {
            String priceType = (String) map.get("priceType");
            if (ObjectUtil.isNotEmpty(priceType)){
                map.put("priceTypeStr", PriceTypeEnum.getNameByValue(priceType));
            }

            String type = (String) map.get("type");
            if (ObjectUtil.isNotEmpty(type)){
                map.put("typeStr", InfoTypeEnum.getNameByValue(type));
            }

            Integer status = (Integer) map.get("status");
            if (ObjectUtil.isNotEmpty(status)){
                map.put("statusStr", BaseStatusEnum.getLabelByValue(status));
            }

            BigDecimal priceAmount = (BigDecimal) map.get("priceAmount");
            BigDecimal priceRate = (BigDecimal) map.get("priceRate");
            map.put("startPrice", NumberUtil.mul(priceRate, priceAmount));

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        System.out.println(NumberUtil.mul(BigDecimal.valueOf(25), BigDecimal.valueOf(0.5)));
    }
}
